package com.tjetc.input;

import org.junit.jupiter.api.Test;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class _2FileReader {


    @Test
    public void testFileReader() throws IOException {
        FileReader reader =
                new FileReader("/Users/gaoyongxiang/百度网盘/IDEA-Java/202507-java-se/chapter16/file/hello.txt");

//        int read = reader.read();
//        System.out.println((char) read);
        int readData = 0;
        while ((readData = reader.read()) != -1) {
            System.out.println((char) readData);
        }
    }

    @Test
    public void testFileReader1() throws IOException {
        FileReader reader =
                new FileReader("/Users/gaoyongxiang/百度网盘/IDEA-Java/202507-java-se/chapter16/file/hello.txt");

        char[] chars = new char[64];
        int len = 0;
        while ((len = reader.read(chars)) != -1) {
            System.out.println(new String(chars, 0, len));
        }
    }


}
